package com.Ajava1801D.线程池;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2020/10/6  16:12
 * 描述:
 */
public class MyRejectedHander implements RejectedExecutionHandler {

    private LinkedBlockingQueue<Runnable> linkedBlockingQueue;

    public MyRejectedHander(LinkedBlockingQueue<Runnable> linkedBlockingQueue) {
        this.linkedBlockingQueue = linkedBlockingQueue;
    }

    @Override
    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {

        try {
            linkedBlockingQueue.put(r);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }
}
